package org.banxico.util;

import java.util.Locale;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringContext {

		private static ClassPathXmlApplicationContext ctx;
		
		public static void load(String ...fileName) {
			ctx=new ClassPathXmlApplicationContext(fileName);
		}
		
		public static <T> T getBean(String idBean, Class<T> clase){
			return ctx.getBean(idBean, clase);
		}
		
		public static ClassPathXmlApplicationContext get(){
			return ctx;
		}
		
		public static void close(){
			ctx.close();
		}
		
		public static String getMessage(String llave){
			return ctx.getMessage(llave, null, null);
		}
		
		public static String getMessage(String llave, Object ...argumentos){
			return ctx.getMessage(llave, argumentos, null);
		}
		
		public static String getMessage(String llave, Locale locale, Object ...argumentos){
			return ctx.getMessage(llave, argumentos, locale);
		}
		
}
